﻿using DTcms.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DTcms.Web.UI.Page
{
    public partial class case_show:Web.UI.BasePage
    {
        protected int id;
        protected Model.dt_channel_article_case model = new Model.dt_channel_article_case();
        protected override void ShowPage()
        {
            this.Init += new EventHandler(case_show_Init);
        }
        /// <summary>
        /// OnInit事件,让频道名称变量先赋值
        /// </summary>
        void case_show_Init(object sender, EventArgs e)
        {
            id = DTRequest.GetQueryInt("id");
            BLL.dt_channel_article_case bll = new BLL.dt_channel_article_case();

            if (id > 0) //如果ID获取到，将使用ID
            {
                if (!bll.Exists(id))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦，您要浏览的页面不存在或已删除！")));
                    return;
                }
                model = bll.GetModel(id);
            }
            //else if (!string.IsNullOrEmpty(page)) //否则检查设置的别名
            //{
            //    if (!bll.ArticleExists(channel, page))
            //    {
            //        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦，您要浏览的页面不存在或已删除！")));
            //        return;
            //    }
            //    model = bll.ArticleModel(channel, page);
            //}
            else
            {
                return;
            }
            //跳转URL
            if (model.link_url != null)
            {
                model.link_url = model.link_url.Trim();
            }
            if (!string.IsNullOrEmpty(model.link_url))
            {
                HttpContext.Current.Response.Redirect(model.link_url);
            }
        }
    }
}
